using System.ComponentModel.DataAnnotations;

namespace DaoHang.Models
{
    /// <summary>
    /// 分类实体类，用于存储网站分类信息
    /// </summary>
    public class Category
    {
        /// <summary>
        /// 分类ID，主键
        /// </summary>
        [Key]
        public int Id { get; set; }

        /// <summary>
        /// 分类名称，最大长度100字符，不可为空
        /// </summary>
        [Required(ErrorMessage = "分类名称不能为空")]
        [MaxLength(100, ErrorMessage = "分类名称不能超过100个字符")]
        public string Name { get; set; } = string.Empty;

        /// <summary>
        /// 分类描述，最大长度500字符
        /// </summary>
        [MaxLength(500, ErrorMessage = "分类描述不能超过500个字符")]
        public string? Description { get; set; }

        /// <summary>
        /// 分类图标CSS类名
        /// </summary>
        [MaxLength(100, ErrorMessage = "图标类名不能超过100个字符")]
        public string IconClass { get; set; } = "bi bi-grid";

        /// <summary>
        /// 排序顺序，数字越小越靠前
        /// </summary>
        public int SortOrder { get; set; } = 0;

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 该分类下的网站列表，导航属性
        /// </summary>
        public virtual ICollection<Website> Websites { get; set; } = new List<Website>();

        /// <summary>
        /// 获取该分类下的网站数量
        /// </summary>
        public int WebsiteCount => Websites.Count;
    }
} 